package com.boot.commons.option;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.ToString;

import java.io.Serializable;


@AllArgsConstructor
@Getter
@ToString
// @JsonFormat(shape = JsonFormat.Shape.OBJECT) // mybatis 序列化 amqp 会出错
public enum SexEnum implements Serializable {



    MAN(0, "男"),
    WOMAN(1, "女"),
    HERMAPHRODITE(2, "中性"),
    NOTAMANNOTFEMALE(3, "人妖");


    private Integer code;

    private String msg;


    /**
     * @param code
     *
     * @return 转换指定枚举实体, mybatis (需要加入handle) 和 json  转换通用
     */

    // @JsonCreator  // 序列生成器
    public static SexEnum getMsgByCode(Integer code) {
        switch (code) {
            case 0:
                return MAN;
            case 1:
                return WOMAN;
            case 2:
                return HERMAPHRODITE;
            case 3:
                return NOTAMANNOTFEMALE;
            default:
                return null;
        }
    }


}
